<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
		$serverName = $_SERVER['HTTP_HOST'];
		if($serverName<>'')
		{
			$zym = explode('.',$serverName);
			if(count($zym)>=3)
			{
				$zjm = $zym[0];
				if(strpos($zjm,'www') !== false){
					redirect(__ROOT__.'/indexdacc8w.php', 0, '');					
				}elseif(strpos($zjm,'mai') !== false){
					//跳转到群成员购买模式
					$this->show('<h1>跳转'.$zjm.'群的买买买店铺</h1>','utf-8');
					$zjm = str_replace("mai","",$zjm);
					redirect(__ROOT__.'index.php/Home/Product/shop/qun/'.$zjm, 0, '');
				}elseif(is_numeric($zjm) == true){
					echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>$zjm群的总库</title>
<frameset rows='100%'>
<frame src='http://www.cc8w.com/index.php/Home/Product/getAllData/qun/$zjm'>
<noframes>
请点击下面链接: <a href='http://www.cc8w.com/index.php/Home/Product/getAllData/qun/$zjm'>link</a>
</noframes>
</frameset>";
				}else{
					redirect(__ROOT__.'/indexdacc8w.php', 0, '');
				}				
			}
			else
			{
				redirect(__ROOT__.'/indexdacc8w.php', 0, '');
			}
		}

		//$this->display();
    }
	public function testHttplib()
	{
	//http://shop.m.taobao.com/shop/coupon.htm?seller_id=716476653&activity_id=ac5936f7569f45fa9c0540131f32d836
	$url = "http://shop.m.taobao.com/shop/coupon.htm?seller_id=2755085538&activity_id=406aee7a14534e1ebc00ef4f198e3833";
	//$url = "http://shop.m.taobao.com/shop/coupon.htm?activityId=$quanid&sellerId=$sellerid";

	//$url = "http://m.taobao.com";
	echo $url;
	vendor('Httplib','','.php');
	$http = new \Httplib($url);
	$http->send();
	$webHtml = $http->response();
	echo $webHtml;
	exit;
	//file_put_contents("test12.html",$webHtml);
	$res = strpos($webHtml,"不存在");
	if($res==false)
	{
		return true;//券可用
	}
	else
	{
		return false;//券不可用
	}	
	
	}
	public function testhttp()
	{
		$url = "http://shop.m.taobao.com/shop/coupon?seller_id=2755085538&activity_id=406aee7a14534e1ebc00ef4f198e3833";
		//$url = "http://shop.m.taobao.com/shop/coupon.htm?activityId=$quanid&sellerId=$sellerid";
	
		//$url = "http://m.taobao.com";
		echo $url;
		vendor('Snoopy.Snoopy#class');
		$snoopy = new \Snoopy;
		
$snoopy->agent = "User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50";

 

	 $snoopy->rawheaders["COOKIE"]="__utmz=17229162.1227682761.29.7.utmccn=(referral)|utmcsr=taobao.com|utmcct=/html/index.html|utmcmd=referral; cdbphpchina_smile=1D2D0D1; cdbphpchina_cookietime=2592000; __utma=233700831.1562900865.1227113506.1229613449.1231233266.16; __utmz=233700831.1231233266.16.8.utmccn=(referral)|utmcsr=localhost:80|utmcct=/test3.php|utmcmd=referral; __utma=17229162.1877703507.1227113568.1231228465.1231233160.58; uchome_loginuser=sinopf; xscdb_cookietime=259200000000; __utmc=1722916; __utmb=17229162009909; cdbphpchina_sid=EX5w1V; __utmc=233700831; cdbphpchina_visitedfid=17; cdbphpchinaO766uPYGK6OWZaYlvHSuzJIP22VpwEMGnPQAuWCFL9Fd6CHp2e%2FKw0x4bKz0N9lGk; xscdb_auth=8106rAyhKpQL49eMs%2FyhLBf3C6ClZ%2B2idSk4bExJwbQr%2BHSZrVKgqPOttHVr%2B6KLPg3DtWpTMUI4ttqNNVpukUj6ElM; cdbphpchina_onlineusernum=3751";
	 
	 if($snoopy->fetch($url))
	 {
	 echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
	 }
	 else
	 echo "error fetching document: ".$snoopy->error."\n";

		
		
	}
	
	 public function qrcode()
	 {//二维码生成
  
		  qrcode("http://www.cc8w.com");  

 	}

}